package com.example.myapplication.video.video_sift;

import android.view.View;

import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.myapplication.R;
import com.example.myapplication.b_entity.Daxia;
import com.example.myapplication.video.video_bean.Video_Bean;
import com.example.myapplication.video.video_bean.Video_Text_Bean;
import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer;

import java.util.List;

public class Video_Adapter extends BaseQuickAdapter<Daxia.DataBean, BaseViewHolder> {


    public Video_Adapter( @Nullable List<Daxia.DataBean> data) {
        super(R.layout.item_video, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, Daxia.DataBean item) {
        helper.addOnClickListener(R.id.frag_videoplay);

}

    public void play(RecyclerView recyclerView,int postion){

        Vido_Ziding vidoplay = (Vido_Ziding) getViewByPosition(recyclerView,postion, R.id.frag_videoplay);

        //设置播放路径
        /*
        @第一个参数：地址
        @第二个参数: 否开启缓存
        @第三个参数：标题

         */

        vidoplay.setUp(Video_Bean.getPlayUrl(postion),true,"");


        //播放
        vidoplay.startPlayLogic();
    }
    public void release(RecyclerView recyclerView,int position){
        Vido_Ziding viewByPosition = (Vido_Ziding) getViewByPosition(recyclerView,position, R.id.frag_videoplay);
        viewByPosition.release();
    }
    public void pause(int postion){
        StandardGSYVideoPlayer viewByPosition = (StandardGSYVideoPlayer) getViewByPosition(postion, R.id.frag_videoplay);
        viewByPosition.setTop(postion);
    }



}
